package gtkwire.widget;

import gtkwire.*;
import java.awt.Color;

/**
*A button to launch a color selection dialog.
*/
public class GtkColorButton extends GtkButton
{
	private String[] createFlag = null;//used to kill supers creating native widgets.

        public GtkColorButton()
        {
                super();
                this.widgetType = WT_GtkColorButton;
		createFlag = new String[0];
		gtkCreate();
		createFlag = null;
        }

	public GtkColorButton( String name, GladeKey key )
	{
		super( name, key );
		widgetType = WT_GtkColorButton;
	}

	protected String[] getCreateData(){ return createFlag; }

	/**
	*Returns selected color.
	*/
	public Color getSelectedColor()
	{
		GTKWireMessage answer = app().sendCommandRequest( name, widgetType, GTKWireCommandRequest.GET_SELECTED_COLOR, null );
		int[] c = (int[]) answer.getMessageObject();
		Color color = new Color( c[ 0 ], c[ 1 ], c[ 2 ], c[ 3 ] );//hard code, gladewire_command.c
		return color;
	}

	/**
	*Sets current color.
	*/
	public void setColor( Color c )
	{
		int[] data = new int[ 4 ];
		data[ 0 ] = c.getRed();
		data[ 1 ] = c.getGreen();
		data[ 2 ] = c.getBlue();
		data[ 3 ] = c.getAlpha();

		app().sendCommand( name, GTKWireCommand.SET_COLOR,  data );
	}

	/**
	*Sets the title for the color selection dialog.
	*/
	public void setDialogTitle( String title )
	{
		app().sendCommand( name, GTKWireCommand.SET_TITLE, title );
	}

}//end class
